import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/index/index.vue'
import Product from '../views/index/components/product.vue'
import Help from '../views/index/components/help.vue'
import Enterprise from '../views/index/components/enterprise.vue'
import Service from '../views/index/components/service.vue'
import Register from '../views/index/components/Register.vue'
import Login from '../views/index/components/Login.vue'

Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  routes: [
    { path: '/', name: 'Index', component: Index },
    { path: '/Product', component: Product },
    { path: '/Help', component: Help },
    { path: '/Enterprise', component: Enterprise },
    { path: '/Service', component: Service },
    { path: '/Register', component: Register },
    { path: '/Login', component: Login }
  ]
})

// 路由守卫
// router.beforeEach((to, from, next) => {
//   const isLogin = localStorage.eleToken ? true : false
//   if (to.path === '/login' || to.path === '/register') {
//     next()
//   } else {
//     isLogin ? next() : next('/login')
//   }
// })

export default router
